package com.wpl.service.impl;

import com.wpl.bean.User;
import com.wpl.bean.Workorder;
import com.wpl.bean.WorkorderExample;
import com.wpl.dao.WorkorderMapper;
import com.wpl.service.IOrderGroupService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 本组工单
 */
@Service
public class OrderGroupServiceImpl implements IOrderGroupService {
    @Resource
    private WorkorderMapper workorderMapper;

    /**
     * 本组工单
     * @param user
     * @return
     */
    @Override
    public List<Workorder> allOrders(User user) {
        WorkorderExample workorderExample = new WorkorderExample();
        WorkorderExample.Criteria criteria = workorderExample.createCriteria();
        criteria.andHandlegroupEqualTo(user.getGroupname());
        criteria.andHandlepersonEqualTo(user.getUsername());
        return workorderMapper.selectByExample(workorderExample);
    }

    /**
     * 本组退单
     * @param user
     * @return
     */
    @Override
    public List<Workorder> allBacks(User user) {
        WorkorderExample workorderExample = new WorkorderExample();
        WorkorderExample.Criteria criteria = workorderExample.createCriteria();
        criteria.andHandlegroupEqualTo(user.getGroupname());
        criteria.andHandlepersonEqualTo(user.getUsername());
        criteria.andOrderstatusEqualTo(0);
        return workorderMapper.selectByExample(workorderExample);
    }
}
